#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

# Ubuntu Jammy enables LTO by default. This is great but this produces a bad
# bitcoin-qt binary on amd64 (Qt5Core segfaults at startup) for some reason, so
# we force disable it.
export DEB_BUILD_MAINT_OPTIONS = optimize=-lto

%:
	dh $@ --buildsystem=cmake+ninja --builddirectory=_build

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=$$(pwd)/debian/tmp \
		-DCLIENT_VERSION_IS_RELEASE=ON \
		-DUSE_JEMALLOC=OFF \
		-DBUILD_LIBBITCOINCONSENSUS=OFF \
		-DBUILD_SEEDER=OFF \
		-DBUILD_IGUANA=OFF

override_dh_auto_test:
	ninja -C _build check

override_dh_auto_install:
	ninja -C _build install/strip
	DESTDIR= xvfb-run ninja -C _build install-manpages

# Skip the dwz step since the files are stripped already.
# https://manpages.debian.org/testing/debhelper/dh_dwz.1.en.html
override_dh_dwz: ;

# Enforce dh_missing to issue warnings when files are present but not installed.
# Note that this is the default with compat level 12.
override_dh_missing:
	dh_missing --list-missing
